<template>
  <a-card :bordered="false">
      
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="单据编号">
              <a-input  v-model="queryParam.billNo" :max-length="36"  placeholder="请输入单据编号" ></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="申请人">
              <select-user-by-dep  :multi="false"
                  v-model="queryParam.employeeId"></select-user-by-dep>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="调整前所属团队">
              <select-team-input  :multi="false" :tdlx="3" v-model="queryParam.beforeTeamId" :teamType="0"  placeholder="请选择调整后所属团队" queryType="parent"/>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="调整后所属团队">
              <select-team-input  :multi="false" :tdlx="3" v-model="queryParam.afterTeamId" :teamType="0"  placeholder="请选择调整后所属团队" queryType="parent"/>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <!--<a-button type="primary" icon="download" @click="handleExportXls('人员调岗单')" :disabled="isDisabledAuth('erpHrEmployeeAdjustPostBill:export')">导出</a-button>
      <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">
        <a-button type="primary" icon="import" :disabled="isDisabledAuth('erpHrEmployeeAdjustPostBill:import')">导入</a-button>
      </a-upload>
      -->
      <!-- 高级查询区域 -->
      <!--<j-super-query :fieldList="superFieldList" ref="superQueryModal" @handleSuperQuery="handleSuperQuery"></j-super-query>-->
      <a-popover title="自定义列" trigger="click" placement="leftBottom">
        <template slot="content">
          <a-checkbox-group @change="onColSettingsChange" v-model="settingColumns" :defaultValue="settingColumns">
            <a-row>
              <template v-for="(item,index) in defColumns">
                <template v-if="item.key!='rowIndex'&& item.dataIndex!='action'">
                  <a-col :span="12"><a-checkbox :value="item.dataIndex">{{ item.title }}</a-checkbox></a-col>
                </template>
              </template>
            </a-row>
          </a-checkbox-group>
        </template>
        <a style="float: right;"><a-icon type="setting" :style='iconStyle'/></a>
      </a-popover>
    </div>

    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;margin-top: 20px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

      <a-table
        ref="table"
        size="middle"
        :scroll="{x:true}"
        :components="draggableComponent"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{getCheckboxProps:getCheckboxProps,selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        class="j-table-force-nowrap"
        @change="handleTableChange">
        <a slot="billNo" slot-scope="text, record" @click="getDetail(record.id)">{{ text }}</a>
        <span slot="link" slot-scope="text, record">
          <a :title="text" @click.stop="handleClick(record)">{{ text }}</a>
        </span>
      </a-table>
    </div>
    <bpm-biz-task-deal-modal ref="taskDealModal" :path="path" :formData="formData" @ok="handleOk"></bpm-biz-task-deal-modal>
    <bpm-process-track-modal ref="bpmProcessTrackModal"></bpm-process-track-modal>
    <biz-task-notify-modal ref="taskNotifyModal"></biz-task-notify-modal>
    <biz-task-notify-me-modal ref="taskNotifyMeModal"></biz-task-notify-me-modal>
    <process-config-modal ref="processConfig" @ok="handleSuccess"></process-config-modal>
  </a-card>
</template>

<script>

  import '@/assets/less/TableExpand.less'
  import { mixinDevice } from '@/utils/mixin'
  import {JeecgBpmListMixin} from '@/mixins/JeecgBpmListMixin'
  import BpmBizTaskDealModal from "@/views/modules/bpmbiz/common/BpmBizTaskDealModal.vue";
  import BpmProcessTrackModal from "@/views/modules/bpmbiz/common/BpmProcessTrackModal.vue";
  import BizTaskNotifyModal from "@/views/modules/bpmbiz/common/BizTaskNotifyModal.vue";
  import BizTaskNotifyMeModal from "@/views/modules/bpmbiz/common/BizTaskNotifyMeModal.vue";
  import ProcessConfigModal from '@/views/scy/components/ProcessConfigModal'
  import { getAction,postAction } from '@/api/manage'
  import {filterMultiDictText} from '@/components/dict/JDictSelectUtil'
  import {DisabledAuthFilterMixin} from '@/mixins/DisabledAuthFilterMixin'
  import SelectUserByDep from '@/views/scy/components/SelectUserByDep'
  import SelectTeamInput from '@/views/scy/components/SelectTeamInput'

  export default {
    name: 'ErpHrEmployeeAdjustPostBillList',
    mixins:[JeecgBpmListMixin, mixinDevice, DisabledAuthFilterMixin],
    components: {
      BpmBizTaskDealModal,
      BpmProcessTrackModal,
      BizTaskNotifyModal,
      BizTaskNotifyMeModal,
      ProcessConfigModal,
      SelectUserByDep,
      SelectTeamInput
    },
    data () {
      return {
        description: '人员调岗单清单',
        //表头
        columns:[],
        //列设置
        settingColumns:[],
        // 列定义
        defColumns: [
          {
            title: '序号',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
          },
          {
            title:'单据编号',
            align:"center",
            width:200,
            scopedSlots: {customRender: 'billNo'},
            dataIndex: 'billNo',
          },
          {
            title:'申请人',
            align:"center",
            width:100,
            dataIndex: 'employeeId_dictText',
            scopedSlots: {
            customRender: 'link'
          },
          },
          {
            title:'预计到岗时间',
            align:"center",
            width:100,
            dataIndex: 'arrivalTime',
            customRender:function (text) {
              return !text?"":(text.length>10?text.substr(0,10):text)
            }
          },
          {
            title:'是否外派',
            align:"center",
            width:80,
            dataIndex: 'isExpatriate_dictText',
          },
          {
            title:'调整前部门',
            align:"center",
            width:200,
            dataIndex: 'beforeDepartId_dictText',
          },
          {
            title:'调整前岗位',
            align:"center",
            width:150,
            dataIndex: 'beforePostId_dictText',
          },
          {
            title:'调整前所属团队',
            align:"center",
            width:200,
            dataIndex: 'beforeTeamId_dictText',
          },
          {
            title:'调整前薪级',
            align:"center",
            width:100,
            dataIndex: 'beforeSalaryScale_dictText',
          },
          {
            title:'调整前车贴（元）',
            align:"center",
            width:200,
            dataIndex: 'beforeVehicleSubsidies',
          },
          {
            title:'调整后部门',
            align:"center",
            width:200,
            dataIndex: 'afterDepartId_dictText',
          },
          {
            title:'调整后岗位',
            align:"center",
            width:100,
            dataIndex: 'afterPostId_dictText',
          },
          {
            title:'调整后所属团队',
            align:"center",
            width:200,
            dataIndex: 'afterTeamId_dictText',
          },
          {
            title:'调整后薪级',
            align:"center",
            width:100,
            dataIndex: 'afterSalaryScale_dictText',
          },
          {
            title:'调整后车贴（元）',
            align:"center",
            width:200,
            dataIndex: 'afterVehicleSubsidies',
          },
          {
            title:'调整原因',
            align:"center",
            width:200,
            dataIndex: 'adjustReason',
            ellipsis: true,
          },
        ],
        url: {
          list: "/api/erp/hr/adjust/erpHrEmployeeAdjustPostBill/allList?bpmStatus=3",
          delete: "/api/erp/hr/adjust/erpHrEmployeeAdjustPostBill/delete",
          deleteBatch: "/api/erp/hr/adjust/erpHrEmployeeAdjustPostBill/deleteBatch",
          exportXlsUrl: "/api/erp/hr/adjust/erpHrEmployeeAdjustPostBill/exportXls",
          importExcelUrl: "/api/erp/hr/adjust/erpHrEmployeeAdjustPostBill/importExcel",
          bizCount: "/api/erp/hr/adjust/erpHrEmployeeAdjustPostBill/bizCount",
          queryEmployeeById: '/api/erp/files/employee/erpEmployeeFile/queryPageById',
        },
        //代码生成后需手动设置流程编码
        flowCode: 'onl_erp_hr_employee_adjust_post_bill',
        formUrl: "/hr/adjust/modules/ErpHrEmployeeAdjustPostBillForm",
        formUrlMobile: "",
        beanName:"ErpHrEmployeeAdjustPostBillServiceImpl",
        dictOptions:{},
        superFieldList:[],
      }
    },
    created() {
      this.getSuperFieldList();
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      },
    },
    methods: {
      //查看详情
      getDetail(id) {
        this.$router.push({
          path: '/erp/hr/adjust/ErpHrEmployeeAdjustPostBillListDetail/'+id,
        })
      },
      initDictConfig(){
      },
      // 跳转至员工档案
      handleClick(record) {
        let that=this
      getAction(this.url.queryEmployeeById,{ id: record.employeeId }).then(res => {
        if(res.success){
          let data=res.result.records;
          if(data){
            that.$router.push({
              path: '/schedule',
              query: {
                id: record.employeeId,
                applyId: data[0].applyId
              }
            }) 
          }
        }
      })
      },
      getSuperFieldList(){
        let fieldList=[];
        fieldList.push({type:'string',value:'bpmStatus',text:'流程状态',dictCode:''})
        fieldList.push({type:'Text',value:'bpmBizTitle',text:'流程标题',dictCode:''})
        fieldList.push({type:'string',value:'billNo',text:'单据编号',dictCode:''})
        fieldList.push({type:'string',value:'employeeId',text:'申请人',dictCode:''})
        fieldList.push({type:'date',value:'arrivalTime',text:'预计到岗时间'})
        fieldList.push({type:'string',value:'isExpatriate',text:'是否外派',dictCode:'yes_or_no'})
        fieldList.push({type:'string',value:'beforeDepartId',text:'调整前部门',dictCode:''})
        fieldList.push({type:'string',value:'beforePostId',text:'调整前岗位',dictCode:''})
        fieldList.push({type:'string',value:'beforeTeamId',text:'调整前所属团队',dictCode:''})
        fieldList.push({type:'string',value:'beforeSalaryScale',text:'调整前薪级',dictCode:''})
        fieldList.push({type:'BigDecimal',value:'beforeVehicleSubsidies',text:'调整前车贴（元）',dictCode:''})
        fieldList.push({type:'string',value:'afterDepartId',text:'调整后部门',dictCode:''})
        fieldList.push({type:'string',value:'afterPostId',text:'调整后岗位',dictCode:''})
        fieldList.push({type:'string',value:'afterTeamId',text:'调整后所属团队',dictCode:''})
        fieldList.push({type:'string',value:'afterSalaryScale',text:'调整后薪级',dictCode:''})
        fieldList.push({type:'string',value:'afterVehicleSubsidies',text:'调整后车贴（元）',dictCode:''})
        fieldList.push({type:'Text',value:'adjustReason',text:'调整原因',dictCode:''})
        fieldList.push({type:'string',value:'isWorkHandover',text:'工作交接',dictCode:'yes_or_no'})
        fieldList.push({type:'string',value:'workHandoverPerson',text:'工作交接人',dictCode:''})
        fieldList.push({type:'string',value:'isOfficeSupplies',text:'办公设备交接情况',dictCode:'yes_or_no'})
        fieldList.push({type:'string',value:'officeSuppliesPerson',text:'办公设备交接人',dictCode:''})
        fieldList.push({type:'string',value:'isLoan',text:'有无借款',dictCode:'yes_or_no'})
        fieldList.push({type:'BigDecimal',value:'loanMoney',text:'借款金额',dictCode:''})
        fieldList.push({type:'Text',value:'remark',text:'备注',dictCode:''})
        fieldList.push({type:'Text',value:'attachment',text:'附件',dictCode:''})
        this.superFieldList = fieldList
      }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>
